package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.roo.addon.entity.RooIdentifier;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

/**
 * The Class TtlsbppaPK.
 */
@Embeddable
@Configurable
@RooIdentifier(dbManaged = true)
public final class TtlsbppaPK implements java.io.Serializable, org.springframework.beans.factory.aspectj.ConfigurableObject {

	/** The cod aplicaci. */
	@Column(name = "COD_APLICACI", nullable = false,columnDefinition = "CHAR", length = 4)
    private String codAplicaci;

	/** The cod paisoalf. */
	@Column(name = "COD_PAISOALF", nullable = false,columnDefinition = "CHAR", length = 2)
    private String codPaisoalf;

	/** The cod objf. */
	@Column(name = "COD_OBJF", nullable = false,columnDefinition = "CHAR", length = 3)
    private String codObjf;

	/**
	 * Instantiates a new ttlsbppa pk.
	 *
	 * @param codAplicaci the cod aplicaci
	 * @param codPaisoalf the cod paisoalf
	 * @param codObjf the cod objf
	 */
	public TtlsbppaPK(String codAplicaci, String codPaisoalf, String codObjf) {
        super();
        this.codAplicaci = codAplicaci;
        this.codPaisoalf = codPaisoalf;
        this.codObjf = codObjf;
    }

	/**
	 * Instantiates a new ttlsbppa pk.
	 */
	@SuppressWarnings("unused")
	private TtlsbppaPK() {
        super();
    }

	/**
	 * Gets the cod aplicaci.
	 *
	 * @return the cod aplicaci
	 */
	public String getCodAplicaci() {
        return this.codAplicaci;
    }

	/**
	 * Gets the cod paisoalf.
	 *
	 * @return the cod paisoalf
	 */
	public String getCodPaisoalf() {
        return this.codPaisoalf;
    }

	/**
	 * Gets the cod objf.
	 *
	 * @return the cod objf
	 */
	public String getCodObjf() {
        return this.codObjf;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (!(obj instanceof TtlsbppaPK)) return false;
        TtlsbppaPK other = (TtlsbppaPK) obj;
        if (codAplicaci == null) {
            if (other.codAplicaci != null) return false;
        } else if (!codAplicaci.equals(other.codAplicaci)) return false;
        if (codPaisoalf == null) {
            if (other.codPaisoalf != null) return false;
        } else if (!codPaisoalf.equals(other.codPaisoalf)) return false;
        if (codObjf == null) {
            if (other.codObjf != null) return false;
        } else if (!codObjf.equals(other.codObjf)) return false;
        return true;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
        final int prime = 31;
        int result = 17;
        result = prime * result + (codAplicaci == null ? 0 : codAplicaci.hashCode());
        result = prime * result + (codPaisoalf == null ? 0 : codPaisoalf.hashCode());
        result = prime * result + (codObjf == null ? 0 : codObjf.hashCode());
        return result;
    }

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/**
	 * To json.
	 *
	 * @return the string
	 */
	public String toJson() {
        return new JSONSerializer().exclude("*.class").serialize(this);
    }

	/**
	 * From json to ttlsbppa pk.
	 *
	 * @param json the json
	 * @return the ttlsbppa pk
	 */
	public static TtlsbppaPK fromJsonToTtlsbppaPK(String json) {
        return new JSONDeserializer<TtlsbppaPK>().use(null, TtlsbppaPK.class).deserialize(json);
    }

	/**
	 * To json array.
	 *
	 * @param collection the collection
	 * @return the string
	 */
	public static String toJsonArray(Collection<TtlsbppaPK> collection) {
        return new JSONSerializer().exclude("*.class").serialize(collection);
    }

	/**
	 * From json array to ttlsbppa p ks.
	 *
	 * @param json the json
	 * @return the collection
	 */
	public static Collection<TtlsbppaPK> fromJsonArrayToTtlsbppaPKs(String json) {
        return new JSONDeserializer<List<TtlsbppaPK>>().use(null, ArrayList.class).use("values", TtlsbppaPK.class).deserialize(json);
    }
}
